<style>
.layui-form-switch {
    min-width: 55px;
}

</style>
<div class="ibox">
        <div class="ibox-title">
        <h5>系统角色管理</h5>
        
<div class="nowrap pull-right" style="margin-top:10px">
    <button data-modal='role/edit' data-title="添加角色" class='layui-btn layui-btn-small'><i class='fa fa-plus'></i> 添加角色</button>
    <a  data-load='role/cache' class='layui-btn layui-btn-small layui-btn-danger' data-confirm="确定要刷新缓存吗？"  href="javascript:void(0)"><i class='fa fa-refresh'></i> 刷新缓存</a>
</div>

    </div>
        <div class="ibox-content fadeInUp animated">
                
<form onsubmit="return false;" data-auto="" method="POST" class="layui-form" >
    <input type="hidden" value="resort" name="action"/>
    <table class="table table-hover">
        <thead>
            <tr>
            <th class='text-center'>ID</th>
                <th class='text-left'>角色名称</th>
                <th class='text-left'>角色描述</th>
                 <th class='text-left'>创建时间</th>
                <th class='text-center'>状态</th>
                <th class='text-center'>操作</th>
            </tr>
        </thead>
        <tbody>
          
        <#list page.data as role>
              <tr>
               <td class='text-center'>${role.id?c}</td>
                <td class='text-left'>${role.title!''}</td>
                <td class='text-left'>${role.desc!''}</td>
                 <td class='text-left'>${(role.createAt?string("yyyy-MM-dd HH:mm:ss"))!}</td>
                <td class='text-center' >
              
                <input type="checkbox" value="${role.id?c}" ${role.status?string("checked","")}  lay-skin="switch"  lay-filter="status" lay-text="启用|停用"/>
                                
                                    </td>
                <td class='text-center nowrap'>
                    <span class="text-explode">|</span>
                    <a data-modal='role/edit?id=${role.id?c}' href="javascript:void(0)" data-title="编辑角色">编辑</a>
                    <span class="text-explode">|</span>
                    <a data-open='role/apply?id=${role.id?c}' href="javascript:void(0)">授权</a>
                   
                    <span class="text-explode">|</span>
                    <a data-load='role/del?id=${role.id?c}' data-confirm="确定要删除吗？"  href="javascript:void(0)">删除</a>
               </td>
            </tr>
            
          </#list>      
            
                    </tbody>
    </table>
    
<p>
<ul class="pagination pull-right"> 
<#import "/common/page.html" as p> 
  <@p.page data=page url="role/index" search_param=search_param />
</ul>
</p>
 
</form>

</div>  
</div>
<script>
layui.use('form', function(){
	  var form = layui.form(); 
	  form.render();
	  form.on('switch(status)', function(data){
	  		var y=this.checked;
	  		var id=this.value;
	  	
	  		$.get("role/updateStatus", {status:(y?1:0),id:id}, function(data1, textStatus, req) {
	  			res=new Object();
	  			res.code = 1;
				res.wait = 3;
				res.msg = (y?'启用':'停用')+'角色操作成功！';
	  			$.msg.auto(res, 1);
	  			/* layer.msg((y?'启用':'停用')+'角色操作成功！', {
	  			      offset: '16px',
	  			      icon:'1'
	  			    });
	  			*/
	  		});
		  });
	});  
	</script>
